package io.github.harmonly.skyblock.type;

import io.github.harmonly.skyblock.util.Replacer;
import org.bukkit.ChatColor;

import java.util.HashMap;

public enum Rank {

    NONE("§7", ChatColor.GRAY, ""),
    VIP("§a[VIP]", ChatColor.GREEN, ""),
    VIP_PLUS("§a[VIP%%plusColor%%§a+]", ChatColor.GREEN, ""),
    MVP("§b[MVP]", ChatColor.AQUA, ""),
    MVP_PLUS("§b[MVP%%plusColor%%+§b]", ChatColor.AQUA, "§c"),
    SUPERSTAR("§6[MVP%%plusColor%%++§6]", ChatColor.GOLD, "§6"),
    YOUTUBE("§c[§fYOUTUBE§c]", ChatColor.RED, ""),
    ADMIN("§c[ADMIN]", ChatColor.RED, "");

    private final String display;
    private final ChatColor color;
    private final String plusColor;

    Rank(String display, ChatColor color, String plusColor) {
        this.display = display;
        this.color = color;
        this.plusColor = plusColor;
    }

    public String getDisplay() {
        return getDisplay(null);
    }

    public String getDisplay(String plusColor) {
        return Replacer.replaceIn(display, "plusColor", (plusColor != null ? ChatColor.valueOf(plusColor) : this.plusColor));
    }

    public ChatColor getColor() {
        return color;
    }

    public String getPlusColor() {
        return plusColor;
    }

    private static HashMap<String, Rank> map = new HashMap<>();

    static {
        map.put("NONE", NONE);
        map.put("VIP", VIP);
        map.put("VIP_PLUS", VIP_PLUS);
        map.put("MVP", MVP);
        map.put("MVP_PLUS", MVP_PLUS);
        map.put("SUPERSTAR", SUPERSTAR);
        map.put("YOUTUBE", YOUTUBE);
        map.put("ADMIN", ADMIN);
    }

    public static Rank getRank(String rank) {
        return map.getOrDefault(rank, NONE);
    }
}
